package com.tianbo.service.imp;

import com.tianbo.common.ModelAndPage;
import com.tianbo.mapper.TOlapXmlnodeMapper;
import com.tianbo.model.TOlapXmlnode;
import com.tianbo.model.TOlapXmlnodeExample;
import com.tianbo.service.OlapXmlnodeService;
import com.tianbo.util.dao.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by Mr.Xu on 2017/9/14.
 */
@Service
public class OlapXmlnodeImpl implements OlapXmlnodeService {
    @Autowired
    private TOlapXmlnodeMapper olapXmlnodeMapper;
    public List<TOlapXmlnode> findXmlnode() throws Exception{
        TOlapXmlnodeExample olapXmlnode=new TOlapXmlnodeExample();
        List<TOlapXmlnode> olapXmlnodelist=olapXmlnodeMapper.selectByExample(olapXmlnode);
        return olapXmlnodelist;
    }
    public List<TOlapXmlnode> selectXmlnode(BigDecimal docid)throws Exception{
        TOlapXmlnodeExample tOlapXmlnodeExample=new TOlapXmlnodeExample();
        tOlapXmlnodeExample.createCriteria().andDocidEqualTo(docid);
        List<TOlapXmlnode> tOlapXmlnodeList=olapXmlnodeMapper.selectByExample(tOlapXmlnodeExample);
        return tOlapXmlnodeList;
    }
    public ModelAndPage findXmlnode(int start, int pagelenth)throws Exception{
        TOlapXmlnodeExample tOlapXmlnodeExample=new TOlapXmlnodeExample();
        Page page=new Page(start,pagelenth);
        tOlapXmlnodeExample.setPage(page);
        int count=olapXmlnodeMapper.countByExample(tOlapXmlnodeExample);
        page.setCount(count);
        List<TOlapXmlnode> tOlapXmlnodeList=olapXmlnodeMapper.selectByExample(tOlapXmlnodeExample);
        ModelAndPage<TOlapXmlnode> modelAndPage=new ModelAndPage<TOlapXmlnode>(tOlapXmlnodeList,page);
        return modelAndPage;
    }
    public void addXmlnode(TOlapXmlnode olapXmlnode){olapXmlnodeMapper.insert(olapXmlnode);}
    public TOlapXmlnode findByid(BigDecimal nodeid)throws Exception{
        TOlapXmlnode olapXmlnode=new TOlapXmlnode();
        olapXmlnode=olapXmlnodeMapper.selectByPrimaryKey(nodeid);
        return olapXmlnode;
    }
    public void updateXmlnode(TOlapXmlnode olapXmlnode){olapXmlnodeMapper.updateByPrimaryKey(olapXmlnode);}
    public int deleteXmlnode(BigDecimal docid){
        TOlapXmlnodeExample olapXmlnodeExample=new TOlapXmlnodeExample();
        olapXmlnodeExample.createCriteria().andDocidEqualTo(docid);
        olapXmlnodeMapper.deleteByExample(olapXmlnodeExample);
        return 1;
    }
    public void deleteByPrimaryKey(BigDecimal nodeid){olapXmlnodeMapper.deleteByPrimaryKey(nodeid);}
}
